<%-- Created by IntelliJ IDEA. --%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
  <head>
    <title>add Cookie</title>
  </head>
  <body>
  <h2>【HuaWei华为】欢迎您访问！</h2>

  <%
    //1.生成序列信息
    String info ;
    String strinfo = null; //临时字符串
    if(application.getAttribute("info")==null)
      application.setAttribute("info","华为");
    else{
      strinfo =application.getAttribute("info").toString() + "-华为";
      application.setAttribute("info",strinfo);
    }

//    out.println("字符=" + application.getAttribute("info").toString() );

    //2.设置Cookie
    Cookie ck1 = new Cookie("name",java.net.URLEncoder.encode( application.getAttribute("info").toString() ,"gbk"));
    ck1.setMaxAge(360); //set timer s
    response.addCookie(ck1);  //ADD COOKIE

  %>

  </body>
</html>